#!/usr/bin/php
Google Sitemap Checker ..WHEEEEE 
<?php 

print_r(($argv));


if (count($argv) != 2) {
	echo "No URL specified.\n;";	
	exit();
}

$mapdata = @file_get_contents($argv[1]);

if (false === $mapdata){
echo "Failed to load URL.\n";
exit();
}

$cdata = "";
$isInLoc = false;

function startElement($parser, $name,$ns){
	global $isInLoc;
	global $cdata;
	
	$isInLoc = (strtolower($name) == 'loc');

	$cdata  = "";
}

function endElement($parser, $name){

	global $isInLoc;
	global $cdata;
	
				
	if (strtolower($name) == 'loc'){

		$url = trim($cdata);
		;
		if (0 < strlen($url)){
				echo ( @file_get_contents($url) === false ) ? "[N]": "[Y]";			
		} else {
			echo "[N]";
		}
		echo "\t" . $url . "\n"; 
		
		$isInLoc == false;
	}

}

function characterData($parser, $data) {

 	global $isInLoc;
     global $cdata;
     	
    if ($isInLoc) {

    	$cdata .= $data;
    }
    
}

$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, true);

xml_set_element_handler($parser, "startElement", "endElement");
xml_set_character_data_handler($parser, "characterData");

xml_parse($parser, $mapdata);

?>

